import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';

/*导航页面 主要显示希望信息*/
void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.teal,
      ),
      home: NavigationPage(),
    );
  }
}

class NavigationPage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<NavigationPage> {
  List<Widget> picwidgets = [];

  List<String> pic = [
    'https://pic3.zhimg.com/80/v2-4a71fb92b82022018384315dd95748de_1440w.jpg?source=1940ef5c',
    'https://pica.zhimg.com/80/v2-24d29c033d9aef226e2085f0dfdc6e96_1440w.jpg?source=1940ef5c',
    'https://pic3.zhimg.com/80/v2-5728dcbf7f7c1bae7a0e9e09166368ad_1440w.jpg?source=1940ef5c',
    'https://pic2.zhimg.com/80/v2-da66beccb2c00ad41965ed0f4609c9a5_1440w.jpg?source=1940ef5c',
    'https://pic1.zhimg.com/80/v2-bc9b74ed04a26696d64b6b064a9b7f61_1440w.jpg?source=1940ef5c',
    'https://pic1.zhimg.com/80/v2-78d133f563b3d6122be1211c952ba15c_1440w.jpg?source=1940ef5c',
    'https://pic3.zhimg.com/80/v2-ec0ab2f946fe655df535eb3dceaf2f2b_1440w.jpg?source=1940ef5c',
    'https://pica.zhimg.com/80/v2-167fe04071223f94b85fd9a1b56ab4f2_1440w.jpg?source=1940ef5c',
    'https://pic1.zhimg.com/80/v2-86cf5c5eb2546b760febb4ce33964e44_1440w.jpg?source=1940ef5c',
    'https://pica.zhimg.com/80/v2-f5d5b862a4c2d02f046e113be032c5f8_1440w.jpg?source=1940ef5c',
    'https://pic3.zhimg.com/80/v2-24bd6a0fbabc6f26de579407ce3238d3_1440w.jpg?source=1940ef5c'
  ];
  List<String> name = [
    '小高不会',
    '小岑哒哒',
    '嘟嘟啪啪',
    '小高熊熊',
    '小都呱呱',
    '小向裂开',
    '二娃子',
    '天天向上',
    '大大小小',
    '球球会中值定理',
    '蓉蓉会泰勒'
  ];
  List<String> sendTime = [
    '刚刚-旅游达人',
    '2小时前-学生',
    '3小时前-知名自媒体人',
    '6小时前-企业员工',
    '9小时前-学生',
    '12小时前-旅游达人',
    '15小时前-电子产品爱好者',
    '16小时前-游戏达人',
    '17小时前-美妆达人',
    '18小时前-体育爱好者',
    '20小时前-影视达人'
  ];
  List<String> descript = [
    '今天我去了北京，真漂亮啊，不愧是北京天安门，很宏伟，很大，很有感触！',
    '水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼',
    '水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼水楼！',
    '我爱学习我爱学习我爱学习我爱学习我爱学习我爱学习我爱学习我爱学习我爱学习我爱学习我爱学习我爱学习我爱学习！',
    '学习爱我学习爱我学习爱我学习爱我学习爱我学习爱我学习爱我学习爱我学习爱我学习爱我学习爱我学习爱我学习爱我！',
    '我发现了，我室友高林串就是个大可爱（shabi）！',
    '今日份美女自拍！',
    '绝绝子啊',
    '美女的是你少管',
    '爱你呦爱你呦爱你呦爱你呦爱你呦爱你呦爱你呦爱你呦爱你呦爱你呦爱你呦爱你呦爱你呦爱你呦爱你呦爱你呦',
    '易烊千玺妈妈爱你！易烊千玺妈妈爱你！易烊千玺妈妈爱你！易烊千玺妈妈爱你！易烊千玺妈妈爱你！易烊千玺妈妈爱你！'
  ];
  List<String> photos = [
    'https://pic3.zhimg.com/80/v2-4a71fb92b82022018384315dd95748de_1440w.jpg?source=1940ef5c',
    'https://pica.zhimg.com/80/v2-24d29c033d9aef226e2085f0dfdc6e96_1440w.jpg?source=1940ef5c',
    'https://pic3.zhimg.com/80/v2-5728dcbf7f7c1bae7a0e9e09166368ad_1440w.jpg?source=1940ef5c',
    'https://pic2.zhimg.com/80/v2-da66beccb2c00ad41965ed0f4609c9a5_1440w.jpg?source=1940ef5c',
    'https://pic1.zhimg.com/80/v2-bc9b74ed04a26696d64b6b064a9b7f61_1440w.jpg?source=1940ef5c',
    'https://pic1.zhimg.com/80/v2-78d133f563b3d6122be1211c952ba15c_1440w.jpg?source=1940ef5c',
    'https://pic3.zhimg.com/80/v2-ec0ab2f946fe655df535eb3dceaf2f2b_1440w.jpg?source=1940ef5c',
    'https://pica.zhimg.com/80/v2-167fe04071223f94b85fd9a1b56ab4f2_1440w.jpg?source=1940ef5c',
    'https://pic1.zhimg.com/80/v2-86cf5c5eb2546b760febb4ce33964e44_1440w.jpg?source=1940ef5c',
    'https://pica.zhimg.com/80/v2-f5d5b862a4c2d02f046e113be032c5f8_1440w.jpg?source=1940ef5c',
    'https://pic3.zhimg.com/80/v2-24bd6a0fbabc6f26de579407ce3238d3_1440w.jpg?source=1940ef5c'
  ];
  @override
  void initState() {}
  @override
  Widget build(BuildContext context) {
    /*搜索发布区域*/
    Widget title = Row(
      children: <Widget>[
        Container(
          color: Colors.white,
          width: MediaQuery.of(context).size.width * 0.68,
          child: TextField(
            decoration: InputDecoration(
                labelText: '请输入搜索关键字',
                hasFloatingPlaceholder: false,
                contentPadding: EdgeInsets.symmetric(vertical: 1),
                prefixIcon: Icon(Icons.search)),
          ),
        ),
        Column(children: <Widget>[
          IconButton(
            alignment: Alignment.topCenter,
            icon: Icon(
              Icons.photo_camera,
            ),
            onPressed: () {
              print('打开照相机');
            },
          ),
          Text(
            '发布',
            style: TextStyle(fontSize: 12, height: 0),
          )
        ]),
      ],
    );
    double width = MediaQuery.of(context).size.width * 0.2;
    List<Widget> getPicWidget() {
      //头像
      List<Widget> pics = [];
      for (int i = 0; i < pic.length; i++) {
        Container container = Container(
            color: Colors.black12,
            width: width,
            height: width,
            child: Column(
              children: <Widget>[
                CircleAvatar(
                  radius: 30,
                  backgroundImage: NetworkImage(
                    pic[i],
                  ),
                ),
                Text(
                  name[i],
                  style: TextStyle(fontSize: 12),
                )
              ],
            ));
        pics.add(container);
      }
      return pics;
    }

    List<Widget> getContenWidget() {
      List<Widget> content = [];
      for (int i = 0; i < pic.length; i++) {
        Column colum = Column(
          children: <Widget>[
            SwitchListTile(
              title: Text(
                name[i],
              ),
              subtitle: Text(sendTime[i]),
              onChanged: (value) {
                print('白嫖取关！');
              },
              value: true,
              secondary: CircleAvatar(
                radius: 20,
                backgroundImage: NetworkImage(pic[i]),
              ),
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(10, 2, 10, 2),
              child: Text(descript[i],style: TextStyle(fontSize: 17),),
            ),
            Image.network(photos[i]),
            Divider(
              height: 5,
              color: Colors.black,
              thickness: 3,
            ) //分割条
          ],
        );
        content.add(colum);
      }
      return content;
    }

    Widget contentList = SingleChildScrollView(
      scrollDirection: Axis.vertical,
      child: Column(
        children: getContenWidget(),
      ),
    );
    Widget guanzhu = SingleChildScrollView(
      scrollDirection: Axis.horizontal,
      child: Row(
        children: getPicWidget(),
      ),
    );
    return Scaffold(
        appBar: AppBar(
          title: title,
        ),
        body: SingleChildScrollView(
          child: Column(
            children: <Widget>[guanzhu, contentList],
          ),
        ));
  }
}
